package org.argeproje.resim.ui.component.filter;

import org.argeproje.resim.proc.filter.AveragePR;
import org.argeproje.resim.property.IntegerPRP;
import org.argeproje.resim.ui.model.ComponentItem;

public class AverageCI extends ComponentItem {

	private static final long serialVersionUID = 1;
	private static final String KERNEL_WIDTH_PROP = "AverageCI._kernelWidth";	
	private int _kernelWidth;	
	public AverageCI()
	{		
		super();
		_name = "Average\nFilter";
		_description = "Box filtering with specified kernel size";
	    initProc();
	}
	
	public void setKernelWidth(int value)
	{
		_kernelWidth = value;
	}
	
	public int getKernelWidth()
	{
		return _kernelWidth;
	}
	
	protected void initDescriptorList()
	{
		super.initDescriptorList();
		registerProperty(new IntegerPRP(this, 
				KERNEL_WIDTH_PROP, "Kernel Width","getKernelWidth", "setKernelWidth"));
	}

	@Override
	public Class<AverageCI> getComponentClass() {
		// TODO Auto-generated method stub
		return AverageCI.class;
	}

	@Override
	public void initProc() {
		if(_processor == null)
		{
			_processor = new AveragePR();			
		}
		_kernelWidth = ((AveragePR)_processor).getParamKernelWidth();
	}
	public void updateProc() {
		if(_processor == null)
		{
			_processor = new AveragePR();			
		}
		((AveragePR)_processor).setParameters(_kernelWidth);
	}
}